package com.farecrawler.app.utils;

import java.util.Calendar;

public class StringUtils {
	
	/**
	 * Method to compute the regular expression to satisfy the string format of "<DD MMM YY>, ddd" 
	 * e.g. "24 Dec 10, Sun"
	 * 
	 * The method computes the date values before concating it with the pattern.
	 * 
	 * @param date
	 * @return
	 */
	public static String getRegexForDate(Calendar date) {
		
		final String pattern = "\\W\\s...";
		
		String day = DateUtils.convertAsDay(date.get(Calendar.DATE));
		String month = DateUtils.getShortMonth(date.get(Calendar.MONTH));
		
		String year = "";
		String tmp = DateUtils.getShortYear(date.get(Calendar.YEAR));
		if(null != tmp) {
			year = tmp;
		}
		
		return day + "\\s" + month + "\\s" + year + pattern;
	}

}
